<!--通用查找-->
<template>
    <div>
        <!--<el-form :inline="true" ref="form" :model="form" :rules="rules">-->
            <!--<el-form-item label="企业名称" prop="name">-->
                <!--<el-input placeholder="企业名称" v-model="form.name"></el-input>-->
            <!--</el-form-item>-->
            <!--<el-form-item label="企业类型" prop="companyId">-->
                <!--&lt;!&ndash;<el-select v-model="form.companyId">&ndash;&gt;-->
                    <!--&lt;!&ndash;<el-option :label="item.name" :value="item.id" v-for="item in form.companyTypelist"></el-option>&ndash;&gt;-->
                <!--&lt;!&ndash;</el-select>&ndash;&gt;-->
                <!--<el-select v-model="form.companyId">-->
                    <!--<el-option label="事业单位" value="0" ></el-option>-->
                    <!--<el-option label="央企" value="1" ></el-option>-->
                    <!--<el-option label="国企" value="2" ></el-option>-->
                    <!--<el-option label="外企" value="3" ></el-option>-->
                    <!--<el-option label="合资" value="4" ></el-option>-->
                    <!--<el-option label="民营企业" value="5" ></el-option>-->
                    <!--<el-option label="其他" value="6" ></el-option>-->
                <!--</el-select>-->
            <!--</el-form-item>-->
            <!--<el-form-item label="上市情况" prop="inmarketId">-->
                <!--&lt;!&ndash;<el-select v-model="form.inmarketId">&ndash;&gt;-->
                    <!--&lt;!&ndash;<el-option :label="item.name" :value="item.id" v-for="item in form.inmarketList"></el-option>&ndash;&gt;-->
                <!--&lt;!&ndash;</el-select>&ndash;&gt;-->
                <!--<el-select v-model="form.inmarketId">-->
                    <!--<el-option label="非上市" value="0" ></el-option>-->
                    <!--<el-option label="沪深A股" value="1" ></el-option>-->
                    <!--<el-option label="上证A股" value="2" ></el-option>-->
                    <!--<el-option label="中小板" value="3" ></el-option>-->
                    <!--<el-option label="创业板" value="4" ></el-option>-->
                    <!--<el-option label="新三板" value="5" ></el-option>-->
                    <!--<el-option label="港股" value="6" ></el-option>-->
                    <!--<el-option label="纳斯达克" value="7" ></el-option>-->
                    <!--<el-option label="其他" value="8" ></el-option>-->
                <!--</el-select>-->
            <!--</el-form-item>-->
                <!--<el-form-item label="涉及领域" prop="field0Id">-->
                    <!--&lt;!&ndash;<el-select v-model="form.field0Id" size="small" style="width:120px" @change="change()">&ndash;&gt;-->
                        <!--&lt;!&ndash;<el-option :label="item.name" :value="item.id" v-for="item in form.involvedfieldList0" :key="item.value" >&ndash;&gt;-->
                        <!--&lt;!&ndash;</el-option>&ndash;&gt;-->
                    <!--&lt;!&ndash;</el-select>&ndash;&gt;-->
                <!--&lt;!&ndash;</el-form-item>&ndash;&gt;-->
                <!--&lt;!&ndash;<el-form-item  prop="field1Id">&ndash;&gt;-->
                    <!--&lt;!&ndash;<el-select v-model="form.field1Id" size="small" style="width:120px" @change="changeThree()" v-if="form.secondLevel.length">&ndash;&gt;-->
                        <!--&lt;!&ndash;<el-option :label="item.name" :value="item.id" v-for="item in form.secondLevel"></el-option>&ndash;&gt;-->
                    <!--&lt;!&ndash;</el-select>&ndash;&gt;-->
                <!--&lt;!&ndash;</el-form-item>&ndash;&gt;-->
                <!--&lt;!&ndash;<el-form-item  prop="field2Id">&ndash;&gt;-->
                    <!--&lt;!&ndash;<el-select v-model="form.field2Id" size="small" style="width:120px" v-if="form.secondLevel.length&&form.thirdLevel.length">&ndash;&gt;-->
                        <!--&lt;!&ndash;<el-option :label="item.name" :value="item.id" v-for="item in form.thirdLevel"></el-option>&ndash;&gt;-->
                    <!--&lt;!&ndash;</el-select>&ndash;&gt;-->
            <!--<el-select v-model="form.field0Id" >-->
                <!--<el-option label="集中热水供应" value="0" ></el-option>-->
                <!--<el-option label="大型公共建筑节能" value="1" ></el-option>-->
                <!--<el-option label="农业废弃物资源化利用" value="2" ></el-option>-->
                <!--<el-option label="餐厨垃圾处理" value="3" ></el-option>-->
                <!--<el-option label="生活垃圾焚烧发电" value="4" ></el-option>-->
                <!--<el-option label="市政污泥集中处理" value="5" ></el-option>-->
                <!--<el-option label="农林生物质发电" value="6" ></el-option>-->
                <!--<el-option label="建筑垃圾资源化处理" value="7" ></el-option>-->
                <!--<el-option label="废旧轮胎资源化利用" value="8" ></el-option>-->
                <!--<el-option label="光伏发电" value="6" ></el-option>-->
                <!--<el-option label="区域能源解决方案" value="7" ></el-option>-->
            <!--</el-select>-->
                <!--</el-form-item>-->
            <!--<el-form-item label="客户经理" prop="manager">-->
                <!--<el-select v-model="form.date1">-->
                    <!--<el-option :label="item.name" :value="item.id" v-for="item in form.companyTypelist"></el-option>-->
                <!--</el-select>-->
            <!--</el-form-item>-->
            <!--&lt;!&ndash;<el-form-item label="编辑人" prop="editMan">&ndash;&gt;-->
                <!--&lt;!&ndash;<el-input placeholder="编辑人" v-model="form.editMan"></el-input>&ndash;&gt;-->
            <!--&lt;!&ndash;</el-form-item>&ndash;&gt;-->
            <!--<el-form-item>-->
                <!--<el-button type="primary" @click="resetForm('form')">重置</el-button>-->
            <!--</el-form-item>-->
            <!--<el-form-item>-->
                <!--<el-button type="primary">查找</el-button>-->
            <!--</el-form-item>-->
        <!--</el-form>-->
        <div class="dateMsg" v-if="pageCount">总计<b>{{pageCount}}</b>条数据</div>
        <div>
            <el-table :data="tableData" style="width: 100%" v-loading="listLoading">
                <el-table-column prop="enterprise_name" label="名称" style="width:50px">
                </el-table-column>
                <el-table-column prop="enterprise_type" label="类型" >
                </el-table-column>
                <el-table-column prop="is_list" label="上市情况">
                </el-table-column>
                <el-table-column prop="involve_field" label="涉及领域" :formatter="banFormatLength">
                </el-table-column>
                <!--<el-table-column prop="power" label="能力项">-->
                <!--</el-table-column>-->
                <el-table-column prop="create_time" label="提交时间">
                </el-table-column>
                <!--<el-table-column prop="editor_person" label="编辑人">-->
                <!--</el-table-column>-->
                <el-table-column prop="account_manager" label="客户经理">
                </el-table-column>
                <el-table-column prop="date" label="操作" >
                    <!--<template scope="scope">-->
                        <!--<el-button size="small" type="info" @click="editRow(scope.$index, scope.row,'editActionDialog')">编辑</el-button>-->
                        <!--<el-button size="small" type="warn" @click="editRow(scope.$index, scope.row,'editActionDialog')">禁用</el-button>-->
                        <!--<el-button size="small" type="danger" icon="delete" @click="editRow(scope.$index, scope.row,'delActionDialog')"></el-button>-->
                    <!--</template>-->
                    <template scope="scope">
                        <el-button  type="text" size="small" @click="handleCheck('checkDiolage',scope.row.enterprise_id)" v-if="limit.limitId20.status==1">审核</el-button>
                        <!--<el-button type="text" size="small" @click="handleEdit('editDiolage',scope.$index, scope.row)">编辑</el-button>-->
                        <el-button type="text" size="small" @click="del(scope.row.enterprise_id)" v-if="limit.limitId22.status==1">弃置此副本</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <div class="pagination" style="width:200px;margin-top:10px;margin-left:75% ">
                <el-pagination layout="prev, pager, next"  :total='pageCount' @current-change="getCurrentpage" :page-size=10></el-pagination>
            </div>
        </div>
         <!--审核企业-->
        <el-dialog title="审核企业" :visible.sync="dialogeShow.checkDiolage" :modal="false" size="small" v-if="dialogeShow.checkDiolage">
            <compCheck></compCheck>
        </el-dialog>
        <!--编辑企业-->
        <el-dialog title="编辑企业" :visible.sync="dialogeShow.editDiolage" :modal="false" size="small" v-if="dialogeShow.editDiolage">
            <compEdit></compEdit>
        </el-dialog>
    </div>
</template>
<script>
    import Bus from '@/config/bus.js'
    import compCheck from '@/components/working/common/compCheck.vue'
    import compEdit from '@/components/working/common/compEdit.vue'
    import _http from '@/components/common/http.vue'
    export default{
        components:{compCheck,compEdit},
        data(){
            return{
                dialogeShow:{
                    checkDiolage:false,
                     editDiolage:false,
                },
                apiPort:{
//                    企业类型接口
                    companytypeApi:'transcript/enterprise/commonSearch',
//                    弃置副本接口
                    giveupApi:"transcript/enterprise/abandon"
                },
                pageAbout:{
                    pageNumber:1,
                    pageSize:10
                },
                pageCount:'',
                listLoading:false,
                currentPage:'',
                limit:'',
                form: {
  //                企业类型接口字典
                    companyTypelist:'',
//                上市情况接口参数
                    inmarketList:'',
//                涉及领域参数
                    involvedfieldList0:'',
                    involvedfieldList1:'',
                    involvedfieldList2:'',
//                涉及领域中间层级
                    secondLevel:[],
//                涉及领域第三层级
                    thirdLevel:[],
                    flag:false,
                    name: '',
                    region: '',
//                    企业类型id
                    companyId: '',
//                    上市情况id
                    inmarketId:'',
//                    涉及领域一级id
                    field0Id: '',
//                    涉及领域二级id
                    field1Id: '',
//                    涉及领域三级id
                    field2Id: '',
                },
                tableData: []
            }
        },
        mounted(){
            this.limit = JSON.parse(localStorage.getItem("limitList"))
            console.log("这里是权限")
            console.log(this.limit.limitId20.status)
            this.userid=localStorage.getItem('userId')
            this.pageAbout.userid = localStorage.getItem('userId')
            var that = this
            this.getTotal()
            Bus.$on('sendflag', function(val){
//                if
                if(val==1){
                    that.getTotal()
                    that.hideDio('checkDiolage')
                }
            });
        },
        methods:{
            //跳转到指定页
            getCurrentpage(val){
                this.listLoading=true
                var that = this
                this.currentPage = val ? val:1
                this.pageAbout.pageNumber=this.currentPage
                var params = that.querystring.stringify(this.pageAbout)
                _http.axiosRequest(that,that.apiPort.companytypeApi,params,(res)=>{
                    that.pageCount=res.data.data.total
                console.log(res)
                this.listLoading=false
                that.tableData = res.data.data.records
            })
            },
//            获取首页数据
            getTotal(){
                this.listLoading=true
                var that = this
                var params = that.querystring.stringify(this.pageAbout)
                _http.axiosRequest(that,that.apiPort.companytypeApi,params,(res)=>{
                    console.log(res)
                that.pageCount=res.data.data.total
                this.listLoading=false
                that.tableData = res.data.data.records
            })
            },
//            change(){
//                this.form.secondLevel=[]
//                for(var a in this.form.involvedfieldList1){
//                    if(this.form.field0Id==this.form.involvedfieldList1[a].father_id){
//                        console.log(this.form.involvedfieldList1[a])
//                        this.form.secondLevel.push(this.form.involvedfieldList1[a])
//                    }
//                }
//            },
////            涉及领域第三级
//            changeThree(){
//                this.form.thirdLevel=[]
//                for(var a in this.form.involvedfieldList2){
//                    if(this.form.field1Id==this.form.involvedfieldList2[a].father_id){
//                        this.form.thirdLevel.push(this.form.involvedfieldList2[a])
//                    }
//                }
//            },
//            获取字典类型接口
//        getType(){
////            获取领域接口
//            _http.axiosGet(that,that.apiPort.involvedfieldApi,(res)=> {
//                that.form.involvedfieldList0 = res.L0
//            that.form.involvedfieldList1 = res.L1
//            that.form.involvedfieldList2 = res.L2
//        })
//
//        },
//
//            组件间传参数，编辑页面
            handleEdit(param,index,raw){
                this.showDio(param)
                setTimeout(function(){
                    Bus.$emit('getTarget',raw)
                },100);
            },
            banFormatLength:function(row,column){
                var ban = row[column.property];
                if ( ban.length >10  ){
                    return ban.replace(',','||').substring(0,10)+'...' ;
                }
                return ban;
            },
//            向查看页面传参 数查看页面
            handleCheck(param,id){
                this.showDio(param)
                setTimeout(function(){
                    Bus.$emit('getCheck',id)
                },100)
             },
//            重置按钮
            resetForm(formName){
                this.$refs[formName].resetFields();
            },
            showDio(parram){
                this.dialogeShow[parram]=true
            },
            hideDio(parram){
                this.dialogeShow[parram]=false
            },
            del(id) {
                var that = this
                this.$confirm('此操作将弃置该副本, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    var param = {enterpriseid:id,userid:that.userid}
                    var params = that.querystring.stringify(param)
                    _http.axiosRequest(that,that.apiPort.giveupApi,params,(res)=>{
                    console.log(res)
                    if(res.data.code==100){
                    that.$message({
                        message: '弃置成功',
                        type: 'success'
                    });
                        that.getCurrentpage(that.currentPage)

                }if(res.data.code==-500){
                    that.$message({
                        message: '企业不存在',
                        type: 'warning'
                    });
                }if(res.data.code==500){
                    that.$message({
                        message: '弃置失败',
                        type: 'warning'
                    });
                }
            })
            }).catch(() => {

            });
            }
        },
        beforeDestroy(){
            Bus.$off("sendflag")
        },
    }
</script>
<style>
    .dateMsg{
        padding-left: 20px;

        padding:10px
    }
</style>